package net.wanho.service.impl;

import cn.afterturn.easypoi.excel.ExcelExportUtil;
import cn.afterturn.easypoi.excel.entity.ExportParams;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import net.wanho.dto.StoreDTO;
import net.wanho.po.Store;
import net.wanho.service.StoreService;
import net.wanho.mapper.StoreMapper;
import net.wanho.vo.PageInfo;
import org.apache.poi.ss.usermodel.Workbook;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;

/**
* @author Administrator
* @description 针对表【store(仓库表)】的数据库操作Service实现
* @createDate 2025-04-28 11:41:58
*/
@Service
public class StoreServiceImpl extends ServiceImpl<StoreMapper, Store>
    implements StoreService{

    @Override
    public PageInfo<Store> rolePageList(int pageNum, int pageSize, StoreDTO storeDTO) {
        Page<Store> page = new Page<>(pageNum, pageSize);
        QueryWrapper<Store> wrapper = new QueryWrapper<>();
        wrapper.like(!ObjectUtil.isEmpty(storeDTO.getStoreName()), "store_name", storeDTO.getStoreName());
        wrapper.eq(!ObjectUtil.isEmpty(storeDTO.getStoreAddress()), "store_address", storeDTO.getStoreAddress());
        wrapper.eq(!ObjectUtil.isEmpty(storeDTO.getConcat()), "concat", storeDTO.getConcat());
        wrapper.eq(!ObjectUtil.isEmpty(storeDTO.getPhone()), "phone", storeDTO.getPhone());
        Page<Store> p = this.baseMapper.selectByPage(page, wrapper);

        PageInfo<Store> pageInfo = new PageInfo<>();
        pageInfo.setPageNum(page.getCurrent());
        pageInfo.setPageSize(page.getSize());
        pageInfo.setTotalNum(page.getTotal());
        pageInfo.setPageCount(page.getPages());
        pageInfo.setLimitIndex(page.offset());
        pageInfo.setResultList(p.getRecords());
        return pageInfo;
    }

    @Override
    public Boolean storeNumCheck(String storeNum) {
        Store store = this.baseMapper.selectOne(new QueryWrapper<Store>().eq("store_num", storeNum));
        return store == null;
    }

}




